const Koa = require('koa');
const app = new Koa();

const Router=require("./my_router")

const serve = require('koa-static');
app.use(serve(__dirname + '/static'));

//跨域模块
var cors = require('koa-cors');
app.use(cors());
//参数解析，文件模块上传大小
const koaBody = require('koa-body');
app.use(koaBody(
  {
    multipart: true,
    formidable: {
      maxFileSize: 1024 * 1024 * 20
    }
  }
));

app
  .use(Router.router.routes())
  .use(Router.router.allowedMethods());

// response
app.use(ctx => {
  ctx.body = 'Hello Koa';
});

app.listen(3000);